<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" th:href="@{/js/layui-v2.4.5/layui/css/layui.css}" media="all" />
    <link rel="stylesheet" th:href="@{/css/public.css}" media="all" />
    <link rel="stylesheet" th:href="@{/js/public/dtree/dtree.css}" media="all" />
    <link rel="stylesheet" th:href="@{/js/public/dtree/font/dtreefont.css}" media="all" />
</head>
<body>

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;-webkit-backface-visibility: hidden;">
    <legend>编辑用户线路关系</legend>
</fieldset>

<form class="layui-form"  lay-filter="example">
    <div class="layui-form-item">
        <label class="layui-form-label">所属类型</label>
        <div class="layui-input-block">
            <select name="type" id ="type" lay-filter="type">
                <option value="0">用户</option>
                <option value="1" >角色</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item" id="selRoleDiv" style="display: none">
        <label class="layui-form-label">所属角色</label>
        <div class="layui-input-block" id="roles" name ="roles" lay-filter="roles">

        </div>
    </div>
    <div class="layui-form-item" id="selUserDiv">
        <label class="layui-form-label">所属用户</label>
        <div class="layui-input-block">
            <div class="layui-input-inline" id="selUserId">
                <select  name="userId" id="userId">
                    <option value="">请通过姓名搜索</option>
                    <th:block th:if="${userHasCallLine!=null}">
                        <option th:value="${userHasCallLine.userId}" th:text="${userHasCallLine.username}" selected="true" ></option>
                    </th:block>
                </select>
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">外呼类型</label>
        <div class="layui-input-block">
            <th:block th:value="${callTypes!=null}">
                <select name="callType" lay-filter="callTypes" id="callType" lay-search="" >
                    <option value="">请选择外呼类型(可输关键词)</option>
                    <option th:each="it:${callTypes}" th:value="${it.value}" th:text="${it.desc}" th:selected="${userHasCallLine!=null && userHasCallLine.callType.value == it.value}"></option>
                </select>
            </th:block>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">线路类型</label>
        <div class="layui-input-block" id="callLineTypes" name ="callLineTypes" lay-filter="callLineTypes">

        </div>
    </div>

    <th:block th:if="${userHasCallLine!=null}">
        <input style="display: none" name="id" th:value="${userHasCallLine.id}">
    </th:block>

    <div class="layui-form-item">
        <div class="layui-input-block" style="text-align: center">
            <button type="button" class="layui-btn layui-btn-normal" id ="back">返回</button>
            <button   class="layui-btn" lay-submit lay-filter="save">保存</button>
        </div>
    </div>
</form>


<script th:src="@{/js/jquery-2.1.1.min.js}"></script>
<script th:src="@{/js/layui-v2.4.5/layui/layui.js}"></script>
<script th:src="@{/js/utils.js}"></script>
<script th:inline="javascript">
//    var username = [[${username}]];
    const baseUrl = [[${#servletContext.contextPath}]];
    var userHasCallLine = [[${userHasCallLine}]];
    var selCallLineTypeVal = [[${selCallLineTypeVal}]];
    console.log(userHasCallLine.userId);
</script>
<script type="text/javascript" th:src="@{/js/page/callConfig/saveOrUpdateUserHasCallLines.js(v=${new java.util.Date().getTime()})}"></script>
</body>
</html>